#include "startwindow.h"
#include "mypushbutton.h"
#include <QPushButton>
#include <QPainter>
#include <QTimer>

StartWindow::StartWindow(QWidget *parent) : mymainwindow(parent)
{
    this->setWindowTitle("欢迎使用多功能导航系统V1.0");
    myPushButton *StartBtn = new myPushButton(this);
    StartBtn->resize(120,120);
    StartBtn->move((this->width()-StartBtn->width())/2,(this->height()*5/6-StartBtn->width()));

    connect(&this->cm,&CountryMap::BacktoStart,[=](){
        this->show();
        this->cm.hide();
    });
    connect(StartBtn,&myPushButton::clicked,[=](){
        StartBtn->setEnabled(false);
         // 播放向下的动画
         StartBtn->moveDown();
         //处理异步
         QTimer::singleShot(150,[=](){
             //播放向上动画
               StartBtn->moveUp();
         });
         QTimer::singleShot(300,[=](){
            StartBtn->setEnabled(true);

            this->hide();
            this->cm.show();
         });


    });

}

void StartWindow::paintEvent(QPaintEvent *ev)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/res/startimg.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);

}
